import { users } from '../data'

export function login() {
    return {
        url: "api/login",
        method: "post",
        response: (opts) => {
            const username = opts.data.username
            if (users.find((v) => v.username === username && v.password === opts.data.password)) {
                return {
                    code: 200,
                    msg: "",
                    data: {
                        token: username + "@asmmpqegqeu90u131rppokwd123mprg",
                        username
                    }
                }
            }
            return {
                code: -1,
                msg: "用户名或密码错误"
            }
        }
    }
}

export function logout() {
    return {
        url: "api/logout",
        method: "get",
        response: {
            code: 200,
            msg: null,
            data: {},
        }
    }
}